#include <iostream>

using namespace std;
int a[300],n;
bool done[300];
bool justic(int a,int b)
{
    int i;
    a+=b;
    for(i=2;i<a;i++)
    {
        if(a%i==0) return false;
    }
    return true;
}
void f(int k)
{
    int i,j;
    if(k==n-1)
    {
        for(i=2;i<=n;i++)
        {
            if(!done[i]&&justic(i,a[0])&&justic(i,a[k-1]))
            {
                a[n-1]=i;
                 for(j=0;j<n-1;j++)cout<<a[j]<<" ";
                    cout<<a[k]<<endl;
                break;
            }
        }
    }
    else
    {
        for(i=2;i<=n;i++)
        {
            if(!done[i]&&justic(i,a[k-1]))
            {
                a[k]=i;
                done[i]=1;
                f(k+1);
                done[i]=0;
            }
        }
    }
}
int main()
{
    int i=1,j;
    while(cin>>n)
    {
        cout<<"Case "<<i++<<":"<<endl;
        fill(done,done+300,0);
        fill(a,a+300,-1);
        a[0]=1;
        done[1]=1;
        f(1) ;
        cout<<endl;
    }
    return 0;
}
